package com.example.receiptocr.home

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import com.example.receiptocr.bodys.responseBodys.ReceiptInfo
import com.example.receiptocr.ui.theme.ReceiptTheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class DetailActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // 从 Intent 获取 Serializable 数据
        val receiptInfo = intent.getParcelableExtra<ReceiptInfo>("receiptInfo")
        if (receiptInfo != null) {
            setContent {
                ReceiptTheme {
                    Surface(
                        modifier = Modifier.fillMaxSize(),
                        color = MaterialTheme.colorScheme.background
                    ) {
                        ReceiptDetailsScreen(
                            receiptInfo = receiptInfo,
                            onNavigateBack = {
                                finish()
                            },
                            onSaveAndReturn = {
                                finish()
                            }
                        )
                    }
                }
            }
        }
    }
}
